package edu.jd.movieplatform.c_admin.info;

import edu.jd.movieplatform.common.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/c_admin/info")
public class InfoAPI {
    @Resource
    private InfoService infoService;

    @Resource
    private CommonService commonService;

    @GetMapping("")
    public Result getInfo(@RequestHeader("Token")String token){
        CurrentManager currentManager = MTokenUtils.getUserInfo(token,commonService);
        return Result.success(infoService.getC_adminInfo(currentManager.getM_id()));
    }

    @PostMapping("")
    public Result getInfo(@RequestBody InfoDto dto,@RequestHeader("Token")String token){
        CurrentManager currentManager = MTokenUtils.getUserInfo(token,commonService);
        dto.setM_id(MTokenUtils.getUserInfo(token,commonService).getM_id());
        infoService.updateInfo(dto);
        return Result.success();
    }
}
